import request from '@/utils/request.js'

export function getArticleList(page, size, searchParams) {
    return request.get('/article/list', {
        params: {
            page: page,
            size: size,
            title: searchParams?.title,
            name: searchParams?.name,
            startTime: searchParams?.searchTime[0],
            endTime: searchParams?.searchTime[1]
        }
    })
}

/**
 * 删除文章id
 * @param articleId
 */
export function remove(articleId) {
    return request.delete(`/article/remove/${articleId}`)
}

/**
 * 详情
 * @param articleId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function detail(articleId) {
    return request.get(`/article/detail/${articleId}`)
}


/**
 * 审核
 * @returns {Promise<axios.AxiosResponse<any>>}
 * @param params
 */
export function audit(params) {
    return request.put("/article/audit/", params)
}


/**
 * 分页获取平台用户数据
 * @param page
 * @param size
 * @param searchParams
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function getArticleUserList(page, size, searchParams) {
    return request.get(`/article/user/list/${page}/${size}`, {
        params: {
            userName: searchParams?.userName,
            status: searchParams?.status,
            phonenumber: searchParams?.phonenumber,
            startTime: searchParams?.startTime,
            endTime: searchParams?.endTime
        }
    })
}


/**
 * 审核平台用户
 * @returns {Promise<axios.AxiosResponse<any>>}
 * @param params
 */
export function statusUser(userId, status) {
    return request.get("/article/user/status", {
            params: {
                userId: userId,
                status: status,
            }
        }
    )
}